package com.wf.classRoomTest.customer;

import java.util.concurrent.ArrayBlockingQueue;

/**
 * @author mpk
 * @since 2024/6/12 15:39:19
 * 消费者
 */
public class MyCustomer extends Thread {

    private ArrayBlockingQueue<String> queue;

    public MyCustomer(ArrayBlockingQueue<String> queue) {
        this.queue = queue;
    }
    @Override
    public void run() {

        while (true) {

            if(!queue.isEmpty()) {
                String product = queue.poll();
                System.out.println("消费者消费了" + product);
            }

        }

    }
}
